﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using Telerik.Web.UI;
using KPIS.GERP.GAMS.DAL;
using KPIS.GERP.GAMS.MODEL;
using System.Transactions;
using System.Collections.Generic;
using System.Globalization;

namespace KPIS.GERP.GAMS.APP.App_UI.Forms
{
    public partial class ACM_Inbox : System.Web.UI.Page
    {
        CultureInfo _thCulture = new CultureInfo("th-TH");
        Commons.Main main = new Commons.Main();
        D_BGM_MAS_Source source = new D_BGM_MAS_Source();
        D_ACM_DepreciationType D_DepreciationType = new D_ACM_DepreciationType();

        
        protected void Page_Load(object sender, EventArgs e)
        {
           

            if (!IsPostBack)
            {

                for (int i = 1; i <= 12;i++ )
                {
                    //DateTime Tempdate = new DateTime(DateTime.Now.Year, i, 1);
                    //ddlBgmMonth.DataValueField = Convert.ToInt32(i).ToString();
                    //ddlBgmMonth.DataTextField = Tempdate.ToString("MMMM", _thCulture);
                    //ddlBgmMonth.DataBind();
                    DateTime Tempdate = new DateTime(DateTime.Now.Year, i, 1);
                    RadComboBoxItem item = new RadComboBoxItem();
                    item.Text = Tempdate.ToString("MMMM", _thCulture);
                    item.Value = Convert.ToInt32(i).ToString();

                    ddlBgmMonth.Items.Add(item);

                    item.DataBind();
                }
               
                txtBgmYear.Text = source.GetCurrentBgmYear();
        }
        }

        

        protected void grdACMVersion_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
        {
           
            if (!e.IsFromDetailTable)
            {


                grdACMAccountAuto.DataSource = D_DepreciationType.SumDepreciationType();

            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            int nEmpSeq = Convert.ToInt32(Session["EmpSeq"]);

            try
            {
                //INSERT Transaction_group case have new group
                foreach (GridDataItem data in grdACMAccountAuto.MasterTableView.GetSelectedItems())
                {
                    M_ACM_Depliciate info = new M_ACM_Depliciate();

                    //info.asset_id = main.ConvertNullInt(main.WebString(data["asset_id"].Text));
              
                    info.asset_code = null;
                    info.record_status = "W";
                    info.created_by = nEmpSeq;
                    info.created_when = DateTime.Now;

                    //string strTranSeq = D_DepreciationType.Insert_Transaction(info);

                   

                    //auto.UpdateRefType(main.WebString(data["ref_type"].Text), Convert.ToInt32(main.WebString(data["ref_seq"].Text)), infoMain.tran_grp_seq.Value);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                LoadGridMaster();
            }
        }
        protected void grdACMAccountAuto_ItemCommand(object source, GridCommandEventArgs e)
        {
            if (e.CommandName == "Filter" || e.CommandName == "Sort" || e.CommandName == "Page")
            {
                LoadGridMaster();
            }
        }
        protected void LoadGridMaster()
        {
            //string strBgmSourceSeq = ddlBgmSourceSeq.SelectedValue;
            string WorkAreaSeq = "1";
            //grdACMAccountAuto.DataSource = auto.GetListMaster(strBgmSourceSeq, WorkAreaSeq);

            grdACMAccountAuto.DataBind();
        }
    }
}

